﻿using System;
using System.Reflection;

namespace ReAnimation.Helpers.Common
{
    public static class ObjectHelper
    {
        public static TValueType GetValueByPropertyName<TValueType>(this object obj,String propertyName) where TValueType : class
        {
            if(obj == null) return null;
            Type t = obj.GetType();
            PropertyInfo propertyInfo = t.GetProperty(propertyName, typeof (TValueType));

            return propertyInfo.GetValue(obj, null) as TValueType;

        }
    }
}
